<?php
if (!empty($_POST)){
    $data = [];
    $formula = str_replace('n','%s',$_POST["formula"]);
    echo "<pre>";
    print_r($formula);
    echo "</pre>";
    die;
    $maxnum = $_POST["maxnum"];
    # 最大值
    for ($i=2;$i<=$maxnum;$i++){
        for($j=1;$j<$i;$j++){
            $k = $i-$j;
            $arithmetic = sprintf($formula,$k,$j,$i);
            array_push($data,$arithmetic);
        }
    }
    $filename = $maxnum."_".md5($formula);
    if(file_put_contents("./library/$filename.json",json_encode($data,1))){
        echo "添加题库成功！";
        header("Location: index.php");
    }
}
?>
<form action="" method="post">

    <input type="text" name="times" value="1">以内算术题
    题型：<select name="type" id="">
        <option value="0">运算</option>
        <option value="1">填空</option>
        <option value="2">比较</option>
    </select>
    运算方式:
    <input type="checkbox" name="operator[]" value="0">加
    <input type="checkbox" name="operator[]" value="1">减
    <input type="checkbox" name="operator[]" value="2">乘
    <input type="checkbox" name="operator[]" value="3">除
    混合次数：<input type="text" name="times" value="1">

</form>